/**
 * @title MainNotificationReceiver.java
 * @package com.esun.rabbit2.viewer
 * @description 
 * @author liugan
 * @date 2012-7-19
 * @copyright 深圳市易讯天空
 */
package com.esun.rabbit2.viewer;

import org.androidpn.client.Constants;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;

/**
 * @title MainNotificationReceiver
 * @description
 * @author liugan
 */
public class MainNotificationReceiver extends BroadcastReceiver {

	private Handler handler;

	public MainNotificationReceiver(Handler handler) {
		this.handler = handler;
	}

	@Override
	public void onReceive(Context context, Intent intent) {
		Log.e("MainNotificationReceiver", "onReceive");
		String action = intent.getAction();
		if (Constants.ACTION_SHOW_NOTIFICATION.equals(action)) {
			// String notificationId = intent.getStringExtra(Constants.NOTIFICATION_ID);
			// String notificationApiKey = intent.getStringExtra(Constants.NOTIFICATION_API_KEY);
			// String notificationTitle = intent.getStringExtra(Constants.NOTIFICATION_TITLE);
			String notificationMessage = intent.getStringExtra(Constants.NOTIFICATION_MESSAGE);
			// String notificationUri = intent.getStringExtra(Constants.NOTIFICATION_URI);
			if (TextUtils.isEmpty(notificationMessage)) {
				return;
			}
			String[] message = notificationMessage.split("#");
			if (message.length != 3) {
				return;
			}
			// 61=表示彩票客户端1.6版本信息 70=表示即时比分客户端信息
			if ("61".equals(message[2])) {
				// 1开奖信息推送
				if ("1".equals(message[1])) {
					handler.sendEmptyMessage(MainAct.LOTTERY_NOTIFICATION);
					// 2激活注册推送
				} else if ("2".equals(message[1])) {

					handler.sendEmptyMessage(MainAct.REGISTER_NOTIFICATION);
					// 3活动运营推送
				} else if ("3".equals(message[1])) {
					handler.sendEmptyMessage(MainAct.ACTIVITY_NOTIFICATION);
					// 4 即时比分定制推送
				} else if ("4".equals(message[1])) {
					// 其他
				} else {

				}
			}
		}

	}
}
